<?php
/*
 * Created on 2012-7-28
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
class rolecontrol_m extends CI_Model{
	function __construct(){
		parent::__construct();
	}
	//根据roleid获取actioninfos
	function get_actioninfos_by_roleid($roleid,$add=''){
		$actionroles = $this->db->get_where('admin_role',array('roleid'=>$roleid))->result_array();
		//user 所在权限所有信息
		$actionroles = $actionroles['0'];
		//该权限所拥有action组
		$actiongroups = explode('_',$actionroles['actiongrouptree']);
		$actionadd = array_merge(explode('_',$actionroles['actionadd']),$add);
		$actioncut = explode('_',$actionroles['actioncut']);
		//所拥有的actions
		$this->db->select('*');
		$this->db->from('admin_action');
		$this->db->where_in('groupid',$actiongroups);
		$this->db->where_not_in('actionid',$actioncut);
		$this->db->or_where_in('actionid',$actionadd);
		$actioninfos = $this->db->get()->result_array();
		return $actioninfos;
	}
	//获取根据user表中增加的actioninfo
	function get_actioninfos_by_actionadd($add){
		$this->db->select('*');
		$this->db->from('admin_action');
		$this->db->where_in('actionid',$add);
		$actioninfos = $this->db->get()->result_array();
		return $actioninfos;
	}
	/*
	 * 根据groupid获取group信息
	 */
	function get_groups_by_groupid($groupids){
		$this->db->select('*');
		$this->db->from('admin_action_group');
		$this->db->where_in('groupid',$groupids);
		$groups = $this->db->get()->result_array();
		return $groups;
	}
	/*
	 * 根据menuid获取menu信息
	 */
	function get_menus_by_menuid($menuids){
		$this->db->select('*');
		$this->db->from('admin_menu');
		$this->db->where_in('menuid',$menuids);
		$menus = $this->db->get()->result_array();
		return $menus;
	}
}
?>
